package com.burst.reptile.modular.zp.warpper;

import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.burst.reptile.common.utils.SecurityUtils;
import com.burst.reptile.common.utils.ToolUtil;
import com.burst.reptile.framework.constant.ConstantFactory;
import com.burst.reptile.framework.web.warpper.BaseControllerWrapper;
import com.burst.reptile.modular.system.entity.SysUser;
import com.burst.reptile.modular.zp.entity.ZpRecAuthor;

public class ZpRecAuthorWrapper extends BaseControllerWrapper<ZpRecAuthor> {

    public ZpRecAuthorWrapper(Page<ZpRecAuthor> page) {
        super(page);
    }
    
    public ZpRecAuthorWrapper(List<ZpRecAuthor> list) {
        super(list);
    }
    
    @Override
    protected void wrapTheMap(ZpRecAuthor recAuthor) {
    	Long userId = recAuthor.getUserId();
    	SysUser user = ConstantFactory.me().getUser(userId);
    	if(ToolUtil.isNotEmpty(user)) {
    		recAuthor.setAvatar(user.getAvatar());
    		recAuthor.setNickName(user.getNickName());
    		recAuthor.setTag(user.getLabel());
    		// 是否关注
        	if(SecurityUtils.isLogin()) {
        		Long loginUserId = SecurityUtils.getLoginUserId();
        		recAuthor.setMutual(ConstantFactory.me().mutual(userId, loginUserId));
        	}
    	}
    }

}
